import tkinter
global Easytk
class Easytk():
    global Easytk
    def create(self,name,length,width,img):
        global Easytk
        Easytk=tkinter.Tk()
        Easytk.title(name)
        Easytk.geometry(length+'x'+width)
        if img!=None:
            root.iconbitmap(img)
    def message(self,content,title,instructions):
        import tkinter.messagebox
        if instructions=='showinfo':
            tkinter.messagebox.showinfo(title,content)
        elif instructions=='showwarning':
            tkinter.messagebox.showwarning(title, content)
        elif instructions=='showerror':
            tkinter.messagebox.showerror(title, content)
        elif instructions=='askokcancel':
            return tkinter.messagebox.askokcancel(title, content)
        elif instructions=='askquestion':
            return tkinter.messagebox.askquestion(title, content)
        elif instructions=='askyesno':
            return tkinter.messagebox.askyesno(title, content)
        elif instructions=='askretrycancel':
            return tkinter.messagebox.askretrycancel(title, content)
        else:
            print('Errow code:No attributes found(message)')
    def file(self,instructions,get):
        import tkinter.filedialog
        global Easytk
        if instructions==asksaveasfilename:
            return tkinter.filedialog.asksaveasfilename(get)
        elif instructions==asksaveasfile:
            return tkinter.filedialog.asksaveasfile(get)
        elif instructions==askopenfilename:
            return tkinter.filedialog.askopenfilename(get)
        elif instructions==askopenfile:
            return tkinter.filedialog.askopenfile(get)
        elif instructions==askdirectory:
            return tkinter.filedialog.askopenfilenames(get)
        elif instructions==askdirectory:
            return tkinter.filedialog.askopenfiles(get)
        else:
            print('Errow code:No attributes found(file)')
            return None
    def part(self,Component_name,sth,address):
        global Easytk
        if Component_name=='Label':
            parts.Label(sth)
        elif Component_name=='Button':
            parts.Button(sth,address)
        elif Component_name=='Enter':
            return parts.Entry()
        else:
            print('Errow code:No attributes found(part)')
            return None
class Parts():
    def Label(self,text):
        global Easytk
        Label=tkinter.Label(Easytk, text=text)
        Label.pack()
    def Button(self,text,address):
        global Easytk
        global address_state
        def state():
            address_state=address
        Button=tkinter.Button(Easytk, text=text,command=state)
        Button.pack()
    def Entry(self):
        global Easytk
        Entry=tkinter.Entry(Easytk)
        Entry.pack()
        return Entry.get()

def create(name,length,width,img):
    easytk.create(name,length,width,img)
def message(content,title,instructions):
    easytk.message(content,title,instructions)
def file(instructions,get):
    easytk.file(instructions,get)
def part(Component_name,sth,address):
    easytk.part(Component_name,sth,address)
def mainloop():
    Easytk.mainloop()
parts=Parts()
easytk=Easytk()
print('0.0.1\nHello easytk!The easytk is by HaiZhi')
